﻿<%@ Page Title="" Language="C#" MasterPageFile="~/default.Master" AutoEventWireup="true" CodeBehind="RoomCheckout.aspx.cs" Inherits="DelonixRegia.RoomCheckout" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphPageTitle" runat="server">
    Room Checkout - Delonix Regia
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cphTitle" runat="server">
    <i class="fa fa-sign-in"></i> Room Checkout
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphSubtitle" runat="server">
    Check out of a Room in Delonix Regia
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="cphMain" runat="server">
    <asp:Panel ID="pnlFirstStep" runat="server">
        <div class="panel panel-default" id="firstStep" style="width: 800px; margin: 0 auto;">
        <div class="panel-heading">
            Checkout a Room
        </div>

        <div class="panel-body">
            <div class="alert alert-danger" id="errorBox" style="display: none;">
            </div>

            <table class="nav-justified">
                <tr>
                    <td class="text-right" colspan="7">
                        <table class="nav-justified" style="width: 500px; margin: 0 auto;">
                            <tr>
                                <td class="text-right" style="width: 117px">Room Number:</td>
                                <td>&nbsp;</td>
                                <td style="width: 113px">
                                    <asp:TextBox ID="tbxRoomNo" runat="server" CssClass="form-control" Width="67px" MaxLength="5"></asp:TextBox>
                                </td>
                                <td class="text-center"><strong>OR</strong></td>
                                <td class="text-right" style="width: 124px">Guest NRIC:</td>
                                <td>&nbsp;</td>
                                <td>
                                    <asp:TextBox ID="tbxGuestNRIC" runat="server" CssClass="form-control" Width="108px" MaxLength="9"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="7" class="text-center">
                        <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btn btn-default btn-lg" OnClientClick="return verifySearch();" OnClick="btnSearch_Click" />
                    </td>
                </tr>
                </table>
        </div>
    </div>
    </asp:Panel>
    

    <asp:Panel ID="pnlSecondStep" runat="server" Visible="false">
        <div class="panel panel-default" id="secondStep" style="width: 800px; margin: 0 auto;">
        <div class="panel-heading">
            Checkout a Room
        </div>

        <div class="panel-body">
            <div class="alert alert-danger" id="Div1" style="display: none;">
            </div>

            <table class="nav-justified">
                <tr>
                    <td colspan="6">
                        <table class="nav-justified" style="width: 600px; margin: 0 auto;">
                            <tr>
                    <td class="text-right" style="width: 179px">Room Number:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 183px">
                        <asp:Label ID="lblRoomNo" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="text-right" style="height: 22px; width: 179px;">Room Type:</td>
                    <td style="height: 22px; width: 15px;"></td>
                    <td style="height: 22px; width: 183px;">
                        <asp:Label ID="lblRoomType" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 179px">
                        <asp:Label ID="lblHiddenBookingID" runat="server" Visible="False"></asp:Label>
                    </td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 183px">&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 179px">Check-in Date &amp; Time:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 183px">
                        <asp:Label ID="lblCheckIn" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 179px">Stated Desired Check-out Date &amp; Time:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 183px">
                        <asp:Label ID="lblCheckOut" runat="server"></asp:Label>
                    </td>
                </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td style="width: 265px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 122px">&nbsp;</td>
                    <td style="width: 127px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-center" colspan="6"><strong>Customer Information</strong></td>
                </tr>
                <tr>
                    <td class="text-center" style="width: 265px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 122px">&nbsp;</td>
                    <td style="width: 127px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 265px">First Name:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 122px">
                        <asp:Label ID="lblFirstName" runat="server"></asp:Label>
                    </td>
                    <td class="text-right" style="width: 127px">Last Name:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblLastName" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="text-right" style="width: 265px">Contact Number:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 122px">
                        <asp:Label ID="lblContact" runat="server"></asp:Label>
                    </td>
                    <td class="text-right" style="width: 127px">Email Address:</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblEmail" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 265px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td style="width: 122px">&nbsp;</td>
                    <td style="width: 127px">&nbsp;</td>
                    <td style="width: 15px">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-center" colspan="6" style="height: 22px">
                        <asp:Button ID="btnProceed" runat="server" Text="Proceed to Checkout" CssClass="btn btn-default btn-lg" OnClick="btnProceed_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="text-center" colspan="6" style="height: 22px">&nbsp;</td>
                </tr>
                <tr>
                    <td class="text-center" colspan="6" style="height: 22px"><a href="RoomCheckout.aspx">&lt; Go back</a></td>
                </tr>
            </table>
        </div>
    </div>
    </asp:Panel>

    <asp:Panel ID="pnlThirdStep" runat="server" Visible="false">
        <div class="panel panel-default" id="thirdStep" style="width: 800px; margin: 0 auto;">
        <div class="panel-heading">
            Checkout a Room
        </div>

        <div class="panel-body">
            <div class="alert alert-danger" id="checkoutErrorBox" style="display: none;">
            </div>

            <table class="nav-justified">
                <tr>
                    <td colspan="6">
                        <table class="nav-justified" style="width:60%; margin: 0 auto;">
                            <tr>
                                <td colspan="3" style="text-align:center;"><strong>Add Mini-Bar Items</strong></td>
                            </tr>
                            <tr>
                                <td style="width: 192px; height: 139px; text-align:right;">Select Mini-Bar Items:</td>
                                <td style="width: 24px; height: 139px"></td>
                                <td style="height: 139px">
                                    <asp:ListBox ID="lbMiniBar" runat="server" Height="137px" Width="255px" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="itemID"></asp:ListBox>
                                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=localhost;Initial Catalog=DelonixRegia;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [itemID], [name] FROM [MiniBar]"></asp:SqlDataSource>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 192px">&nbsp;</td>
                                <td style="width: 24px">&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="3" style="text-align:center;">
                                    <asp:Button ID="btnAdd" runat="server" CssClass="btn btn-lg" Text="Add" OnClick="btnAdd_Click" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="6" style="text-align:center;"><h4>Checkout Invoice</h4></td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">First Name:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvFirstName" runat="server" Text="Dan"></asp:Label>
                    </td>
                    <td style="width: 124px; text-align:right;">Last Name:</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvLastName" runat="server" Text="Ong"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">NRIC Number:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvNRIC" runat="server" Text="S9437363H"></asp:Label>
                    </td>
                    <td style="width: 124px; text-align:right;">Address:</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvAddress" runat="server" Text="318 Sembawang Vista"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Contact Number:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvContact" runat="server" Text="96607278"></asp:Label>
                    </td>
                    <td style="width: 124px; text-align:right;">Email Address:</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvEmail" runat="server" Text="dan@gmail.com"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">No of Adult(s):</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvNoOfAdults" runat="server" Text="3"></asp:Label>
                    </td>
                    <td style="width: 124px; text-align:right;">No of Children:</td>
                    <td>&nbsp;</td>
                    <td>
                        <asp:Label ID="lblInvNoOfChildren" runat="server" Text="3"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Check-In Date &amp; Time:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:Label ID="lblInvCheckIn" runat="server" Text="12th May 2014 12:00:00 PM"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Check-Out Date &amp; Time:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:Label ID="lblInvCheckOut" runat="server" Text="15th May 2014 12:00:00 PM"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Room Number:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:Label ID="lblInvRoomNo" runat="server" Text="1334"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="height: 22px; width: 267px; text-align:right;">Room Type:</td>
                    <td style="height: 22px; width: 21px"></td>
                    <td colspan="4" style="height: 22px">
                        <asp:Label ID="lblInvRoomType" runat="server" Text="Presidential Suite"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Total Number of Guest(s):</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:Label ID="lblInvTotalGuest" runat="server" Text="6"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Total Number of Days Stayed:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:Label ID="lblInvTotalDays" runat="server" Text="4"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Room Rate:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvRoomRate" runat="server" Text="200"></asp:Label>/day
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Total Price for Stay:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvTotalStayPrice" runat="server" Text="4800"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Added Mini-Bar Items:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        <asp:ListBox ID="lbInvMiniBar" runat="server" Height="137px" Width="255px"></asp:ListBox>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Total Price for Mini-Bar Items:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvMiniBarPrice" runat="server" Text="37.50"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Gross Total:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvGrossTotal" runat="server" Text="4837.50"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Add GST (7%):</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvGST" runat="server" Text="338.60"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px; text-align:right;">Total Payable:</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td colspan="4">
                        $<asp:Label ID="lblInvTotalPayable" runat="server" Text="5176.10"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="6" style="text-align:center;">
                        <asp:Button ID="btnCompleteCheckout" runat="server" CssClass="btn btn-lg" Text="Complete Checkout" OnClick="btnCompleteCheckout_Click" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="6" style="text-align:center;"><a href="RoomCheckout.aspx">< Go back</a></td>
                </tr>
                <tr>
                    <td style="width: 267px">&nbsp;</td>
                    <td style="width: 21px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td style="width: 124px">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>

        </div>
    </div>
    </asp:Panel>

    <asp:Panel ID="pnlFourthStep" runat="server" Visible="false">
        <div class="panel panel-default" id="fourthStep" style="width: 800px; margin: 0 auto;">
            <div class="panel-heading">
                Successful! - Checkout a Room
            </div>

            <div class="panel-body">
                <div class="alert alert-success" id="successBox" style="text-align:center;">
                    Room has been successfully checked out!
                </div>
            </div>
            <div style="text-align:center"><asp:Button ID="btnGoBack" runat="server" Text="< Go back to Dashboard" CssClass="btn btn-default btn-lg" OnClick="btnGoBack_Click" /></div><br />
        </div>
    </asp:Panel>
    

    <script type="text/javascript">
        function transitionToSecondStep() {
            $('#secondStep').hide().show('slide', { direction: 'right', easing: 'easeOutQuart', duration: 250 });
        }

        function transitionToThirdStep() {
            $('#thirdStep').hide().show('slide', { direction: 'right', easing: 'easeOutQuart', duration: 250 });
        }

        function transitionToFourthStep() {
            $('#fourthStep').hide().show('slide', { direction: 'right', easing: 'easeOutQuart', duration: 250 });
        }

        function verifySearch() {
            var RoomNo = $('#cphMain_tbxRoomNo').val();
            var GuestNRIC = $('#cphMain_tbxGuestNRIC').val();

            if ((RoomNo.length == 0) && (GuestNRIC.length == 0)) {
                $('#errorBox').html('<strong>Error:</strong> You need to enter either the <i>Room Number</i> or <i>Guest\'s NRIC</i>!');
                $('#errorBox').hide().show();
                return false;
            }

            if (is_int(RoomNo) != true) {
                $('#errorBox').html('<strong>Error:</strong> Invalid datatype! You need to enter a number for Room Number.');
                $('#errorBox').hide().show();
                return false;
            }
        }

        $('#cphMain_tbxRoomNo').focus().keydown(function () {
            $('#errorBox').hide();
        });

        $('#cphMain_tbxGuestNRIC').keydown(function () {
            $('#errorBox').hide();
        });

        function is_int(value) {
            for (i = 0 ; i < value.length ; i++) {
                if ((value.charAt(i) < '0') || (value.charAt(i) > '9')) return false;
            }
            return true;
        }
    </script>
</asp:Content>
